cmake_minimum_required(VERSION 3.19)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)
project(RobotControl)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_compile_options(-std=c++17)

set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_package(Qt5 COMPONENTS Core Widgets  SerialPort REQUIRED)
get_target_property(QtCore_location Qt5::Widgets LOCATION)
foreach (plugin ${Qt5Network_PLUGINS})
    get_target_property(_loc ${plugin} LOCATION)
    message("Plugin ${plugin} is at location ${_loc}")
endforeach ()

find_package(glog REQUIRED)
find_package(fmt REQUIRED)
# windows 平台关闭窗口
if (WIN32)
    add_executable(${PROJECT_NAME} WIN32
            main.cpp
            )
else ()
    add_executable(${PROJECT_NAME}
            main.cpp
            robotinfo.cpp
            RobotInfo.ui
            SerialThread.cpp
            )
endif ()
find_library ( QWT_LIBRARY
        NAMES qwt qwt-qt5
        HINTS ${QT_LIBRARY_DIR}
        )
#[[MESSAGE("=======Searching for QWT======")
FIND_PATH(QWT_INCLUDE_DIR NAMES qwt_plot.h PATHS
        ${QT_INCLUDE_DIR}
        PATH_SUFFIXES qwt
        )
MESSAGE(${QWT_INCLUDE_DIR})
FIND_LIBRARY(QWT_LIBRARY NAMES qwt PATHS
        ${QT_INCLUDE_DIR}/lib
        )
MESSAGE(${QWT_LIBRARY})

#设置项目包含目录，包括将第三方库附加
INCLUDE_DIRECTORIES(
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${Projects_QT5_Includes}
        ${QWT_INCLUDE_DIR}
)
# 将第三方库附加到变量Projects_Extra_Libraries中，便于管理
list(APPEND Projects_Extra_Libraries ${QWT_LIBRARY})]]


target_link_libraries(${PROJECT_NAME}
        Qt5::Widgets
        Qt5::Core
        Qt5::SerialPort
        glog
        fmt
        pthread
        )

